package com.wl.dzt.ide.controller;

import com.wl.dzt.ide.service.ScriptGenderService;
import com.wl.dzt.sys.ui.ext.ExtTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author wl_code@163.com
 * @version 1.0
 * @date 2018/7/5/005
 * @description Js生成控制器
 */
@Api(description = "jsGenerator", tags = "Js生成控制器(basic-api)")
@Controller
@RequestMapping("jsGenerator")
public class JsGeneratorController {
    /**
     * 脚本服务
     */
    @Resource
    private ScriptGenderService scriptGenderService;

    /**
     * <b>实体列表</b>
     * <p>
     * 实体列表
     * </p>
     *
     * @param response 响应
     */
    @ApiOperation("实体列表")
    @PostMapping("list")
    public void list(HttpServletResponse response) {
        ExtTemplate.treeTemplate(scriptGenderService.entityList(), response);
    }

    /**
     * <b>创建模板</b>
     * <p>
     * 创建模板
     * </p>
     *
     * @param modelType 模块类型
     * @param clazz     实体类
     * @param response  响应
     */
    @ApiOperation("创建模板")
    @PostMapping("createJs")
    public void createJs(String modelType, String clazz, HttpServletResponse response) {
        scriptGenderService.createScript(modelType, clazz);
    }
}
